/**
 * Created by 落叶的思恋 on 2017/2/8.
 */

$(function () {
    var topul = $('.topul>li>a');
    $(topul[0]).addClass("select");
    var centerul = $('.outer>ul');
    topul.click(function () {
        ss = 0;
        var i = 0;
        for (i = 0; i < topul.length; i++) {
            $(topul[i]).removeClass("select");
            $(this).addClass("select");
        }
        for (var i = 0; i < topul.length; i++) {
            if ($(topul[i]).hasClass("select")) {


            }
        }
    });

    /**
     * 头部活动
     *
     */
    var startX = 0, endX = 0, moveX = 0;

    $('.topul>li>a').on('touchstart touchmove touchend', function (event) {
        switch (event.type) {
            case 'touchstart':
                startX = event.originalEvent.touches[0].clientX;

                break;


            case 'touchmove':
                endX = event.originalEvent.touches[0].clientX;
                moveX = endX - startX;

                var widthW = window.innerWidth;
                var width = $('.topul').css('width');
                var left = $('.topul').css('left');
                width = parseInt(width) / 4;
                left=parseInt(left);
                if (moveX > 0) {
                    if(left<0){
                        $('.topul').css('left',left+ moveX+ "px");
                    }if(left>=0){
                        $('.topul').css('left', 0+ "px");
                    }


                }
                if (moveX < 0 ) {
                    if(left<=-width*4){
                        $('.topul').css('left', -width*4+ "px");
                    }if(left>-width*4){
                        $('.topul').css('left', left+moveX+ "px");
                    }


                }
                break;

            case 'touchend':



        }


    })
    $('.s').click(function(){

    });
});